//
//  MCCameraCustom.m
//  CreditGroup
//
//  Created by ltl on 15/9/11.
//  Copyright (c) 2015年 JPlay. All rights reserved.
//

#import "MCCameraCustom.h"
#import "MCCameraEventProcess.h"
@interface MCCameraCustom ()

@property (strong, nonatomic) MCCameraEventProcess *eventClass;

@end

@implementation MCCameraCustom

- (instancetype)init
{
    self = [super init];
    if (self)
    {
        NSLog(@"MCCameraCustom init is success");
        [self installRegister];
    }
    return self;
}
- (void)setIsHaveFrame:(EMCCameraIsHaveFrame)isHaveFrame{
    _isHaveFrame = isHaveFrame;
}

- (void)setIsClip:(EMCCameraIsClip)isClip{
    _isClip = isClip;
    self.eventClass.isClip = _isClip;
}


- (void)setRotation:(EMCImageRotationType)rotation{
    _rotation = rotation;
}

- (void)setSize:(CGSize)size{
    _size = size;
}

- (void)setFormat:(EMCImageFormat)format{
    _format = format;
}

- (void)setQuality:(CGFloat)quality{
    _quality = quality;
}

- (void)installRegister
{
    __weak MCCameraCustom *weakself = self;
    self.eventClass = [[MCCameraEventProcess alloc] init];
    self.eventClass.isClip = _isClip;
    self.eventClass.rotation = _rotation;
    self.eventClass.size     = _size;
    self.eventClass.format   = _format;
    self.eventClass.quality  = _quality;
    self.eventClass.type     = _type;
    self.eventClass.returnImageBlock= ^(UIImage *image)
    {
        // 拿到相机/相册返回的图片
        weakself.cameraCustomReturnImageBlock(image);
        
    };
    
    self.eventClass.returnImageDataBlock = ^(NSData *imageData){
        weakself.cameraCustomReturnImageDataBlock(imageData);
    };
    
}

- (void)callCorrespondingClassByType:(EActionSheetEventType)type{
    
    [self.eventClass transmitClickEventsWithActionSheetType:type isHaveFrame:_isHaveFrame];
    
}

- (void)dealloc{
    NSLog(@"MCCameraCustom = nil");
}

@end
